local que_yizhong = fk.CreateSkill {
    name = "que_yizhong",
    anim_type = "control",
    tags = { Skill.Compulsory },
}
Fk:loadTranslationTable {
    ["que_yizhong"] = "役中",
    [":que_yizhong"] = "锁定技，你的回合开始时，你需要依次进行两次体力或体力上限，数值为1点的调整，本回合结束时，回退本次调整。",

    ["changeMaxHp"] = "调整上限",
    ["changeHp"] = "调整体力",
}
que_yizhong:addEffect(fk.TurnStart, {
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(que_yizhong.name) and target == player
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local olx = player:getMark("que_yifa")
        for i = 1, 2 + olx, 1 do
            local chs = { "changeMaxHp", "changeHp" }
            if room:askToChoice(player, {
                    choices = chs,
                    skill_name = que_yizhong.name,
                    prompt = "役种：请选择要调整的数值", }) == "changeMaxHp" then
                chs = { "+1", "-1" }
                if room:askToChoice(player, {
                        choices = chs,
                        skill_name = que_yizhong.name,
                        prompt = "役种：请选择增加或减少该值", }) == "+1" then
                    room:changeMaxHp(player, 1)
                    room:addPlayerMark(player, "zhong_upmaxhp-turn")
                else
                    room:changeMaxHp(player, -1)
                    room:addPlayerMark(player, "zhong_downmaxhp-turn")
                end
            else
                chs = { "+1", "-1" }
                if not player:isWounded() then
                    table.removeOne(chs, "+1")
                end
                if room:askToChoice(player, {
                        choices = chs,
                        skill_name = que_yizhong.name,
                        prompt = "役种：请选择增加或减少该值",
                        all_choices = chs }) == "+1" then
                    room:changeHp(player, 1, nil, que_yizhong.name)
                    room:addPlayerMark(player, "zhong_uphp-turn")
                else
                    room:changeHp(player, -1, nil, que_yizhong.name)
                    room:addPlayerMark(player, "zhong_downhp-turn")
                end
            end
        end
    end,
})
que_yizhong:addEffect(fk.TurnEnd, {
    can_refresh = function(self, event, target, player, data)
        local n = player:getMark("zhong_upmaxhp-turn") + player:getMark("zhong_downmaxhp-turn") +
            player:getMark("zhong_uphp-turn") +
            player:getMark("zhong_downhp-turn")
        return player:hasSkill(que_yizhong.name) and target == player and n > 0
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        if player:getMark("zhong_upmaxhp-turn") > 0 then
            room:changeMaxHp(player, -player:getMark("zhong_upmaxhp-turn"))
        end
        if player:getMark("zhong_downmaxhp-turn") > 0 then
            room:changeMaxHp(player, player:getMark("zhong_downmaxhp-turn"))
        end
        if player:getMark("zhong_uphp-turn") > 0 then
            room:changeHp(player, -player:getMark("zhong_uphp-turn"), nil, que_yizhong.name)
        end
        if player:getMark("zhong_downhp-turn") > 0 then
            room:changeHp(player, player:getMark("zhong_downhp-turn"), nil, que_yizhong.name)
        end
    end
})

return que_yizhong
